package cn.stylefeng.guns.modular.gui.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.gui.entity.Shequ;
import cn.stylefeng.guns.modular.gui.model.params.ShequParam;
import cn.stylefeng.guns.modular.gui.service.ShequService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 小区管理控制器
 *
 * @author Dong
 * @Date 2023-06-09 14:52:13
 */
@Controller
@RequestMapping("/shequ")
public class ShequController extends BaseController {

    private String PREFIX = "/shequ";

    @Autowired
    private ShequService shequService;

    /**
     * 跳转到主页面
     *
     * @author Dong
     * @Date 2023-06-09
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/shequ.html";
    }

    /**
     * 新增页面
     *
     * @author Dong
     * @Date 2023-06-09
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/shequ_add.html";
    }

    /**
     * 编辑页面
     *
     * @author Dong
     * @Date 2023-06-09
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/shequ_edit.html";
    }

    /**
     * 新增接口
     *
     * @author Dong
     * @Date 2023-06-09
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(ShequParam shequParam) {
        this.shequService.add(shequParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author Dong
     * @Date 2023-06-09
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(ShequParam shequParam) {
        this.shequService.update(shequParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author Dong
     * @Date 2023-06-09
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(ShequParam shequParam) {
        this.shequService.delete(shequParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author Dong
     * @Date 2023-06-09
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(ShequParam shequParam) {
        Shequ detail = this.shequService.getById(shequParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author Dong
     * @Date 2023-06-09
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(ShequParam shequParam) {
        return this.shequService.findPageBySpec(shequParam);
    }
    
    
    /**
     * 查询所有职位
     *
     * @author stylefeng
     * @Date 2019-03-13
     */
    @ResponseBody
    @RequestMapping("/getgglist")
    public LayuiPageInfo getgglist(@RequestParam(value = "sid", required = false) Long sid) {
        return this.shequService.listGg(sid);
    }

}


